Skip to content

feat(sdk-coin-dot): integrate @bitgo/wasm-dot for WASM-based transaction parsing#8272

Closed
bitgo-ai-agent-dev[bot] wants to merge 1 commit intomasterfrom
feat/T1-13-wasm-dot-parsing
Closed

feat(sdk-coin-dot): integrate @bitgo/wasm-dot for WASM-based transaction parsing#8272
bitgo-ai-agent-dev[bot] wants to merge 1 commit intomasterfrom
feat/T1-13-wasm-dot-parsing

Conversation

@bitgo-ai-agent-dev
Copy link

Summary

Integrates @bitgo/wasm-dot into sdk-coin-dot for WASM-based extrinsic parsing, replacing @polkadot/api-based decoding for signed tdot transactions.

  • wasmParser.ts (new): exports explainDotTransaction() and toJsonFromWasm(). Parses extrinsics via DotTransaction.fromHex() + parseTransaction(), derives transaction types, extracts inputs/outputs with BitGoJS-specific semantics (e.g. proxy deposit cost for batch stake/unstake), and maps to the existing TxData / TransactionExplanation interfaces for backwards compatibility.
  • transaction.ts: toJson() routes signed tdot transactions through the WASM path. Unsigned transactions and mainnet dot remain on the legacy txwrapper path until WASM validation is complete.
  • lib/index.ts: exports explainDotTransaction and its public types (ExplainDotTransactionParams, DotWasmExplanation, DotInput).
  • package.json: adds @bitgo/wasm-dot ^1.3.0 dependency.
  • webpack/bitgojs.config.js: adds ESM alias for browser builds so @bitgo/wasm-dot uses the fetch-based WASM loader instead of fs.readFileSync.
  • test/unit/wasmParser.ts: unit tests covering transfers, staking bond, batch stake/unstake, tip/fee handling, and display order.

Why WASM parsing is needed for signed tdot transactions

Westend (tdot) adds non-standard signed extensions (AuthorizeCall, StorageWeightReclaim) between the signature and call data. The JS txwrapper decoder doesn't know about these extensions and misidentifies the call data boundary. The WASM decoder reads the runtime metadata to determine the extension layout before parsing, so it handles any chain correctly.

Scope

WASM path is gated by this._coinConfig.name === 'tdot' && this._signedTransaction. Mainnet dot and all unsigned transactions continue using the existing txwrapper path.

Test plan

  • Unit tests in test/unit/wasmParser.ts pass — covers transfer, bond, batch stake, full unstake, fee/tip, displayOrder
  • Existing sdk-coin-dot tests continue to pass (no changes to unsigned or mainnet paths)

TICKET: BTC-3068

🤖 Generated with Claude Code

…ion parsing

Replaces @polkadot/api-based transaction decoding with WASM-backed parsing
for signed tdot transactions. Unsigned transactions and mainnet dot remain
on the legacy txwrapper path until validation is complete.

Changes:
- wasmParser.ts: new module exporting explainDotTransaction() and
  toJsonFromWasm(); parses extrinsics via DotTransaction.fromHex() +
  parseTransaction(), derives transaction types, extracts inputs/outputs,
  handles batch stake/unstake proxy deposit cost semantics, and maps to
  the existing TxData / TransactionExplanation interfaces for backwards
  compatibility
- transaction.ts: toJson() routes signed tdot transactions through the
  WASM path; the signed extrinsic bytes carry metadata-aware signed
  extension layout that the JS decoder cannot handle (Westend adds
  AuthorizeCall + StorageWeightReclaim)
- lib/index.ts: exports explainDotTransaction and its public types
- package.json: adds @bitgo/wasm-dot ^1.3.0 dependency
- webpack/bitgojs.config.js: adds ESM alias for browser builds so
  @bitgo/wasm-dot uses the fetch-based WASM loader instead of fs
- test/unit/wasmParser.ts: unit tests for transfers, staking bond,
  batch stake, full unstake, tip/fee handling, and display order

TICKET: BTC-3068

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@linear
Copy link

linear bot commented Mar 10, 2026

Copy link
Contributor

@zahin-mohammad zahin-mohammad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failing CI

@lcovar
Copy link
Contributor

lcovar commented Mar 10, 2026

didnt mean to open this

@lcovar lcovar closed this Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants